<!DOCTYPE html>
<html>

<head lang="en">
    <meta charset="UTF-8">
    <title>父级页面</title>
</head>
<p>a页面</p>
<body>
    <iframe style="display:none;" id="frame" src="http://127.0.0.1:4000/b.html"></iframe>
    <script type="text/javascript">
        window.onload = function () {
            let frame = document.getElementById("frame")
            // 给子页面传递数据
            frame.contentWindow.postMessage("a.html页面内容", "http://127.0.0.1:4000/")
            window.onmessage = function (e) {
                //判断消息来源
                if (e.origin == 'http://127.0.0.1:4000') {
                    //得到子页面的信息
                    document.write(e.data)
                }
            }
        }
    </script>
</body>

</html>